package main

import "fmt"

// 定义一个user类型
type user struct {
	name  string
	email string
}

// notify使用 值接收者 实现一个方法
func (u user) notify() {
	fmt.Printf("Sending User Email To %s<%s>\n", u.name, u.email)
}

func (u *user) changeEmail(email string) {
	u.email = email
}

func main() {
	bill := user{"Bill", "bill@email.com"}
	bill.notify()

	lisa := &user{"Lisa", "Lisa@email.com"}
	lisa.notify()
	(*lisa).notify()
	fmt.Println(lisa, *lisa)

	bill.changeEmail("bill@doamin.com")
	bill.notify()
	(&bill).changeEmail("bill@doamin2.com")
	bill.notify()

	lisa.changeEmail("lisa@domain.com")
	lisa.notify()
	// dict := make(map[string]int)
	dict := map[string]string{"Red": "#da1337", "Orange": "#e95a22"}
	changeDict(dict)
	fmt.Println(dict)
}

func changeDict(dict map[string]string) {
	dict["yellow"] = "#ffffe4"
}
